package models

type BaseModel struct {
	Id        uint  `gorm:"primary_key" json:"id"`
	CreatedAt int64 `json:"createdAt" gorm:"column:createdAt"`
	UpdatedAt int64 `json:"updatedAt" gorm:"column:updatedAt"`
}

type User struct {
	BaseModel
	Username   string `json:"username" gorm:"unique;size:255"`
	Password   string `json:"password"`
	Role       string `json:"role"`
	BargeShip  string `json:"bargeShip"`
	FisherShip string `json:"fisherShip"`
}

type Record struct {
	BaseModel
	Date           string `json:"date" gorm:"size:255;uniqueIndex:idx_date_bargeShip"`
	BargeShip      string `json:"bargeShip" gorm:"size:255;uniqueIndex:idx_date_bargeShip"`
	FisherShip     string `json:"fisherShip"`
	Audit          string `json:"audit"`
	Num            string `json:"num"`
	Weight         string `json:"weight"`
	SalvageArea    string `json:"salvageArea"`
	Disposal       string `json:"disposal"`
	DisposalMethod string `json:"disposalMethod"`
	Pics           string `json:"pics"`
	State          string `json:"state"`
	YmState        string `json:"ymState"`
	YmText         string `json:"ymText"`
	Bh             string `json:"bh" gorm:"-"`
}

func (r Record) Set(key string, value string) {
	switch key {
	case "date":
		r.Date = value
	case "bargeShip":
		r.BargeShip = value
	case "fisherShip":
		r.FisherShip = value
	case "audit":
		r.Audit = value
	case "weight":
		r.Weight = value
	case "salvageArea":
		r.SalvageArea = value
	case "disposal":
		r.Disposal = value
	case "disposalMethod":
		r.DisposalMethod = value
	case "pics":
		r.Pics = value
	case "state":
		r.State = value
	case "ymState":
		r.YmState = value
	case "ymText":
		r.YmText = value
	}
}

type BargeShip struct {
	BaseModel
	Name    string `json:"name" gorm:"unique;size:255"`
	Northid string `json:"northid"`
	MMSI    string `json:"mmsi" gorm:"unique;size:255"`
}

type FisherShip struct {
	BaseModel
	Name    string `json:"name" gorm:"unique;size:255"`
	Owner   string `json:"owner"`
	Kw      string `json:"kw"`
	Length  string `json:"length"`
	MMSI    string `json:"mmsi" gorm:"unique;size:255"`
	Northid string `json:"northid" gorm:"unique;size:255"`
	SeaArea string `json:"seaArea"`
}

type SalvageArea struct {
	BaseModel
	Name string `json:"name"`
}

type DisposalRecord struct {
	BaseModel
	Date             string `json:"date"`
	BargeShip        string `json:"bargeShip"`
	Audit            string `json:"audit"`
	Weight           string `json:"weight"`
	DisposalMethod   string `json:"disposalMethod"`
	DisposalPosition string `json:"disposalPosition"`
}

type Test struct {
	BaseModel
	Name string `json:"name"`
}
